﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess.Classes;

namespace Webmau.Controls
{
    public partial class DatPhong : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            hplChiTiet.Visible = false;
            if (!IsPostBack)
            {

                drMail.DataTextField = "DuoiEmail";
                drMail.DataValueField = "IDEmail";
                drMail.DataSource = Email.LayDanhSach();
                drMail.DataBind();

            }
        }
        protected void btnDangki_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["id"] == null)
                {
                    Response.Redirect("DangNhap.aspx");
                }
                else
                {
                    if (Session["id"] != null)
                    {

                        DatPhong1 data = new DatPhong1();
                        data.IDNguoiDung = Session["id"].ToString();
                        data.IDPhongTro = Convert.ToInt32(Request.QueryString["IDDanhSach"].ToString());
                        data.Email = txtEmail.Text + drMail.Text;
                        data.SoDT = txtSoDT.Text;
                        data.DiaChi = txtDiaChi.Text;
                        data.NgayDat = Convert.ToDateTime(DateTime.Now.ToShortDateString().ToString());
                        DatPhong1.Them(data);
                        lbThongBao.Text = "Đặt phòng thành công!!";
                        hplChiTiet.Visible = true;
                    }


                }
            }
            catch
            {
            }
        }
    }
}